package com.zlzxm.shoesmarket.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.zlzxm.shoesmarket.TestConstant;
import com.zlzxm.shoesmarket.net.repository.RecordRepository;
import com.zlzxm.shoesmarket.net.respone.BaseResponse;
import com.zlzxm.shoesmarket.util.RxAndroidHelp;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityRepositoryInOutNote;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;

/**
 * CREATE BY zlzxm ON 4/14/21
 */
public class VMRepositoryInOutNote extends BaseViewModel {

    RecordRepository recordRepository = new RecordRepository();

    private MutableLiveData<List<EntityRepositoryInOutNote>> liveNote = new MutableLiveData<>();

    public MutableLiveData<List<EntityRepositoryInOutNote>> getLiveNote() {
        return liveNote;
    }


    public void requestNote(){

        recordRepository.listIn("1", "10")
                .compose(RxAndroidHelp.turn())
                .subscribe(new Consumer<BaseResponse<String>>() {
                    @Override
                    public void accept(BaseResponse<String> stringBaseResponse) throws Throwable {

                    }
                },throwableCallback);



    }

    //<editor-fold defaultState="collapsed" desc="测试">


    private List<EntityRepositoryInOutNote> createNotes(){

        List<EntityRepositoryInOutNote> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {

            EntityRepositoryInOutNote entityRepositoryInOutNote = new EntityRepositoryInOutNote();

            entityRepositoryInOutNote.setCode("sss-ss");
            entityRepositoryInOutNote.setBrand("耐克");
            entityRepositoryInOutNote.setSize("xxx-xx");
            entityRepositoryInOutNote.setTime("2020-02x");
            entityRepositoryInOutNote.setPrice("-2222");
            entityRepositoryInOutNote.setNum("2222");
            entityRepositoryInOutNote.setProfit("-21111222");
            entityRepositoryInOutNote.setFace(TestConstant.PIC_SIX);


            list.add(entityRepositoryInOutNote);
        }

        return  list;

    }


    // </editor-fold>
}
